#include <iostream>
#include <thread>
#include <mutex>
#include "thread_pool.hpp"

#define println(str) \
do {             \
          std::cout << str << std::endl;       \
} while(0)

int main() {
    std::cout << "start" << std::endl;
    auto& pool = get_thread_pool(8);
    for (int i = 0; i < 100; i++) {
        if (i == 56) {
            pool.add_task_unsafe([=] {
                {
                    std::this_thread::sleep_for(std::chrono::seconds(1));
                    std::cout << i << std::endl;
                }
            }, 3);
            continue;
        }
        pool.add_task_unsafe([=] {
            {
                std::this_thread::sleep_for(std::chrono::seconds(1));
                std::cout << i << std::endl;
            }
        });
    }
    println(pool.get_task_queue_size());
    pool.start();
    std::this_thread::sleep_for(std::chrono::seconds(8));
    pool.force_stop_gracefully();
    return 0;
}
